using System.IO;
using Avalonia.Media;
using Serilog;
using torch.plugin_manager;
using torch.plugin;

namespace torch.ui.Views;
using System;
using Avalonia.Controls;

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        // LoadPlugin();
    }
    
    
    private void LoadPlugin()
    {
        string currentDirectory = Directory.GetCurrentDirectory();
        string pluginDirectory = Path.Combine(currentDirectory, "plugin");
        PluginManager pluginManager = new PluginManager(pluginDirectory);
        var list = pluginManager.LoadPlugins();
        foreach (var plugin in list)
        {
            Log.Information($"已加载插件: {plugin.Name}");

            var panel = new Panel();
            var control = plugin.GetUserInterface();
            panel.Width = plugin.Size.Width;
            panel.Height = plugin.Size.Height;
            panel.Background = Brushes.Chocolate;
            panel.Children.Add(control);
            var box = this.FindControl<StackPanel>("box");
            
            box.Children.Add(panel);
        }
    }
}